import Vue from 'vue'
import App from './App.vue'
import router from './router'
// 引入 Element UI
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import axios from 'axios'

Vue.config.productionTip = false
axios.interceptors.request.use(req=>{
  if(localStorage.getItem("token")){
    req.headers["token"]=localStorage.getItem("token");
  }
  return req;
})

axios.interceptors.response.use(resp=>{
  if(resp.headers.token){
    localStorage.setItem("token",resp.headers.token)
  }
  return resp;
})

// 注册 Element UI
Vue.use(ElementUI)

Vue.prototype.$http = axios

axios.interceptors.request.use(req=>{
  if(localStorage.getItem("token")){
    req.headers["token"]=localStorage.getItem("token");
  }
  return req;
})
axios.defaults.baseURL = "http://192.168.50.8"

axios.defaults.headers.common['token'] = localStorage.getItem('token')



new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
